﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using JN.Utility;
using Power.BLL;
using Power.Model;

namespace LogManager
{
    public enum AlarmType
    {
        Low,
        Middle,
        High,
    }
    public static class AlarmLogger
    {
        #region property
        private static Sys_alarmBLL alarmBLL = new Sys_alarmBLL();
        private static object lockWrite = new object();

        #endregion

        public static void Write(AlarmType type, string devices, string info, string stationId)
        {
            lock (lockWrite)
            {
                try
                {
                    Sys_alarm mAlarm = new Sys_alarm();
                    mAlarm.alarm_device = devices;
                    mAlarm.alarm_info = info;
                    mAlarm.alarm_time = DateTime.Now;
                    mAlarm.alarm_type = type.ToString();
                    mAlarm.station_id = stationId;

                    alarmBLL.Add(mAlarm);
                }
                catch (Exception ex)
                {
                    SystemLogger.Write(ex);
                }
            }
        }
    }
}
